<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Core.DAL" %>

<asp:Content ID="cHead" ContentPlaceHolderID="cphHead" runat="server">
    <% this.Page.Title = (string)ViewData["PageTitle"]; %>
</asp:Content>


<asp:Content ID="cMainContent" ContentPlaceHolderID="cphMainContent" runat="server">
<div id="administration">
    <div id="emailList" class="loader">
        <ul></ul>
    </div>
</div>      
</asp:Content>

<asp:Content ID="cScripts" ContentPlaceHolderID="cphJScripts" runat="server">

<script id="emailTmpl" type="text/x-jquery-tmpl">
   <li>
        <h1 class="header">${AuthorName} - ${Title}</h1>
        <span>${$item.ConvertToDate(PubDate)}</span>
        <div class="content">
            ${Summary}<br />
            <a href="${Link}" target="_blank">Plus...</a>
        </div>
   </li>
</script>

<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "/Administration/GetEmail",
            success: function (mailItems) {
                $("#emailList").removeClass("loader");
                if (mailItems != null && mailItems.length > 0) {
                    $.template("emailTmplCompiled", $("#emailTmpl"));

                    $.tmpl("emailTmplCompiled", mailItems, {
                        ConvertToDate: function (item) {
                            return $.ParseJsonDateTime(item);
                        }
                    }).appendTo("#emailList ul");
                } else {
                    $("#emailList").parent().prepend(displayError("<%= ScoutNET.Resources.Administration_Email_NoMessageFound %>"));
                }
            }
        });
    })
</script>
</asp:Content>

